using UnityEngine;
using System.Collections;

public class AutoDestruct : MonoBehaviour {
	
	public float SecondsBeforeAutodestruct;
	
	// Use this for initialization
	void Start () 
	{
		if(SecondsBeforeAutodestruct != 0)
			SetSuicide(SecondsBeforeAutodestruct);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
	
	public IEnumerator Suicide(float pSecond)
	{
		yield return new WaitForSeconds(pSecond);
		
		Destroy(gameObject);
	}
	
	public void SetSuicide(float pSeconds)
	{
		StartCoroutine(Suicide(pSeconds));
	}
}
